Sampling Theorem

A continuous time signal can be represented in its samples and can be recovered back when sampling frequency fs is greater than or equal to the twice the highest frequency component of message signal.

$$f_s \leq 2 f_m$$

In [1]:
%matplotlib inline
import numpy as np
import scipy
from matplotlib import pyplot as plt

In [2]:
# Consider a signal x(t) = sin ωt , where ω = 2πft and f = 50Hz
f = 10 # (Hz) Signal's Frequency

fs_1 = 15 # (Hz) Sampling Rate 1 (Below Nquist Rate (< 2f))
fs_2 = 20 # (Hz) Sampling Rate 2 (at Nquist Rate (= 2f))
fs_3 = 100 # (Hz) Sampling Rate 3 (above Nquist Rate (> 2f))

# Function to compute the time range
computeTimeRange = lambda fs: np.arange(-0.2, 0.2, 1 / fs)

# Computing the sample interval
t_1 = computeTimeRange(fs_1)
t_2 = computeTimeRange(fs_2)
t_3 = computeTimeRange(fs_3)

# Computing the signal for each interval
x_1 = np.sin( 2 * np.pi * f * t_1)
x_2 = np.sin( 2 * np.pi * f * t_2)
x_3 = np.sin( 2 * np.pi * f * t_3)

In [3]:
# plotting the signals
plt.plot(t_3, x_3, c="cyan")

# red points - > Nquist Rate
# blue points - = Nquist Rate
# green points - < Nquist Rate
plt.plot(t_3, x_3, 'bo', c="red")
plt.plot(t_2, x_2, 'bo', c="blue")
plt.plot(t_1, x_1, 'bo', c="green")

plt.xlabel('time')  
plt.ylabel('Amplitude')  
plt.title('10Hz signal in Time Domain')   
plt.grid(True) 
plt.show()